import { http } from "@/utils/http";
import type { ResultProps } from "@/api/user";
import type { DeviceProp } from "@/api/teaInfuser/device";

export interface GroupProp {
  device_num: number;
  id: number;
  account_id: number;
  business_id: number;
  parent_id: number;
  name: string;
  info: string;
  icon: string;
  type: string;
  delete_status: number;
  expand: boolean;
  update_time: Date;
  create_time: Date;
}

export interface StoreProp {
  id: number;
  account_id: number;
  business_id: number;
  logo: null | string;
  name: string;
  province: string;
  city: string;
  detail_address: null | string;
  operator: null | string;
  phone: null | string;
  device_num: number;
  device_locknum: number;
  group_id: number;
  store_status: number;
  delete_status: number;
  update_time: Date;
  create_time: Date;
  group_name: null | string;
  assign_accountid: number | null;
  cash_id: null | string;
  deviceData: DeviceProp[];
}

export const getGroupList = (data?: object) => {
  return http.request<ResultProps<GroupProp[]>>("post", "/storeGroup/getList", {
    data
  });
};

export const addStoreGroup = (data?: object) => {
  return http.request<ResultProps<GroupProp>>("post", "/storeGroup/add", {
    data
  });
};

export const uptStoreGroup = (data?: object) => {
  return http.request<ResultProps<GroupProp>>("post", "/storeGroup/upd", {
    data
  });
};

export const delStoreGroup = (data?: object) => {
  return http.request<ResultProps<GroupProp>>("post", "/storeGroup/del", {
    data
  });
};

export const getStoreList = (data?: object) => {
  return http.request<ResultProps<StoreProp[]>>("post", "/store/getList", {
    data
  });
};

export const addStore = (data?: object) => {
  return http.request<ResultProps<any>>("post", "/store/add", {
    data
  });
};

export const updStore = (data?: object) => {
  return http.request<ResultProps<any>>("post", "/store/upd", {
    data
  });
};

// 撤店
export const updStoreStatusStore = (data?: object) => {
  return http.request<ResultProps<any>>("post", "/store/updStoreStatus", {
    data
  });
};

export const delStore = (data?: object) => {
  return http.request<ResultProps<any>>("post", "/store/del", {
    data
  });
};

export const configGetList = (params?: object) => {
  return http.request<ResultProps<any>>("get", "/config/getList", {
    params
  });
};

export const configAdd = (data?: object) => {
  return http.request<ResultProps<any>>("post", "/config/add", {
    data
  });
};

export const configUpd = (data?: object) => {
  return http.request<ResultProps<any>>("post", "/config/upd", {
    data
  });
};

export const addList = (data?: object) => {
  return http.requestJson<ResultProps<any>>(
    "post",
    "/store/addList",
    {
      data
    },
    {
      beforeResponseCallback() {}
    }
  );
};
